{% extends "personal_center/base.html" %}

{% block page_link %}
    <link rel="stylesheet" href="../../static/public_file/css/PersonnelChooser.css">
{% endblock %}


{% block style %}
    <style>
        .add_class {
            background: #1E90FF;
        }

        .add_background {
            background: #A9A9A9;
        }

        tr {
            height: 35px;
        }

        th {
            text-align: center;
        }

        table {
            table-layout: fixed;
        }

        table td {
            padding-right: 10px;outline: none;
        }

        td:first-child, th:first-child {
            position: sticky;
            left: 0; /* 首行永远固定在左侧 */
            z-index: 1;
        }

        thead tr th {
            position: sticky;
            top: 0; /* 列首永远固定在头部  */
            background-color: #E8E8E8;
        }

        th:first-child {
            z-index: 2;
        }

        .li-class {
            list-style: none;
            margin-top: 2%;
            color: #0b0b0b;
            cursor: pointer;
        }

        .top_tag {
            border-bottom: #01AAED solid 2px;
            color: #01AAED;
        }

        .tab_top {
            width: 100px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            display: inline-block;
            cursor: pointer;
        }

        .button_for_control {
            width: 90px;
            height: 30px;
            border: 1px solid #99D3F5;
            background: #D0EEFF;
            border-radius: 4px;
            letter-spacing: 0;
            line-height: 30px;
            color: #089bab;
        }
        #page_one button:hover {
            color: red;
        }

        .input-style {
            display: inline-block;
            width: 100%;
            height: 35px;
            font-size: 14px;
            border: none;
            background: white;
        }

        .shade {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(36, 36, 36, 0.5);
            display: none;
            z-index: 10000;
        }

        #ThreeNavigation div {
            padding-left: 2%;
        }
    </style>
{% endblock %}


{% block right_content %}
    <div style="width: 100%;height: 40px;background: white;border-bottom: #A9A9A9 solid 0.5px;line-height: 40px;padding-left: 1%;color: black;">
        <div id="notice_detail" class="tab_top top_tag">
            <i class="iconfont icon-zhangdan_xiangqing_o" style="font-size: 20px;"></i> 审批详情
        </div>

        <div id="" style="width: 100px;float: right;text-align: center;margin-right: 1%;height: 40px;">
            <button id="" onmousemove="page_zhanshi()" onmouseout="page_yincang()"
                    style="width: 100px;height: 30px;line-height: 27px;border: #1E90FF solid 1px;background: #1E90FF;color: white;margin-top: 5px;border-radius: 3px;">
                操作
            </button>
        </div>


        <div id="page_one" onmousemove="page_zhanshi()" onmouseout="page_yincang()"
             style="z-index: 1000; position: absolute; width: 100px; height: auto;right: 1.3%; top: 80px;background: #FFFFFF; box-shadow: rgb(204 204 204) 2px 2px 10px;padding: 5px;display: none;">
            <button onclick="but_click()" class="button_for_control">
                打印
            </button>

            {% if is_audit == 'true' %}
                <button onclick="online_tag()" id="summit_button" class="button_for_control">
                    审批
                </button>
            {% endif %}

            {% if is_edit == 'true' %}
                <button onclick="ExportCar()" class="button_for_control">
                    提交
                </button>
            {% endif %}

            {% if is_stop == 'true' %}
                <button id="is_stop" onclick="operate_button(this.id)" class="button_for_control">
                    终止
                </button>
            {% endif %}
        </div>
    </div>

    <div id="appave-model" class="shade">
        <div id="examine-model" style="width: 700px;background: white;left: 50%;top: 50%;position: absolute;transform: translate(-50%, -50%);">
            <div id="appave-title" style="width: 100%;height: 40px;border-bottom: #cfcfcf solid 1px;font-size: 14px;cursor: move;">
                <div style="width: 40%;height: 40px;line-height: 40px;text-align: left;padding-left: 1%;letter-spacing: 2px;float: left;">
                    审批
                </div>
                <div style="width: 59%;height: 40px;letter-spacing: 2px;float: left;">
                    <div onclick="close_models()" style="width: 40px;height: 40px;text-align: center;line-height: 40px;cursor: pointer;float: right;">
                        <i class="iconfont icon-quchu"></i>
                    </div>
                </div>
            </div>

            <div style="width: 100%;font-size: 14px;background: #E8E8E8;padding-top: 1%;">
                <div style="width: 98%;height: 150px;margin-left: 1%;background: white;padding-top: 1%;padding-left: 1%;border-radius: 3px;padding-right: 1%;">
                    <div style="width: 100%;height: 35px;line-height: 35px;border-bottom: #E8E8E8 solid 1px;padding-left: 1%;">
                        基本信息
                    </div>
                    <div style="width: 100%;height: 125px;padding-left: 1%;">
                        <div style="width: 100%;height: 50px;">
                            <div style="width: 49%;height: 50px;float: left;padding-left: 1%;color: #B5B5B5;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;line-height: 50px;">
                                <span style="color: #9C9C9C;">用车事由：</span>{{ v_obj.subject }}
                            </div>
                            <div style="width: 49%;height: 50px;float: right;padding-left: 1%;color: #B5B5B5;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;line-height: 50px;">
                                <span style="color: #9C9C9C;">行车路线：</span>{{ v_obj.route }}
                            </div>
                        </div>

                        <div style="width: 100%;height: 50px;">
                            <div style="width: 49%;height: 50px;float: left;padding-left: 1%;color: #B5B5B5;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;line-height: 50px;">
                                <span style="color: #9C9C9C;">用车人员：</span>{{ v_obj.field_leader }}
                            </div>
                            <div style="width: 49%;height: 50px;float: right;padding-left: 1%;color: #B5B5B5;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;line-height: 50px;">
                                <span style="color: #9C9C9C;">用车时间：</span>{{ v_obj.start_time|date:'Y-m-d H:i' }}
                            </div>
                        </div>
                    </div>
                </div>

                <div style="width: 98%;margin-left: 1%;background: white;padding-top: 1%;padding-left: 1%;border-radius: 3px;margin-top: 1%;padding-right: 1%;padding-bottom: 20px;">
                    <div style="width: 100%;height: 35px;line-height: 35px;border-bottom: #E8E8E8 solid 1px;padding-left: 1%;">
                        意见
                    </div>
                    {% if v_obj.state == 'fg' %}
                        <div style="width: 100%;margin-top: 10px;padding-left: 2%;">
                            <select name="" id="select_tag" style="border-radius: 3px;border: #cfcfcf solid 1px;width: 250px;height: 30px;outline: none;">
                                <option value="">请选择车辆</option>
                                {% for vehicle in vehicle_list %}
                                    <option value="">{{ vehicle.number }}</option>
                                {% endfor %}
                            </select>

                            <select name="" id="select_drive" style="border-radius: 3px;border: #cfcfcf solid 1px;width: 250px;height: 30px;outline: none;margin-left: 2%;">
                                <option value="">请选择司机</option>
                                {% for driver in driver_list %}
                                    <option value="">{{ driver.name }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    {% endif %}
                    <div style="width: 100%;">
                        <textarea id="opinion_detail" placeholder="请输入审批意见" style="width: 96%;height: 100px;margin-left: 2%;margin-top: 1%;border: #cfcfcf solid 1px;outline: none;font-size: 14px;" ></textarea>
                    </div>
                </div>

                <div style="width: 100%;height: 40px;background: white;margin-top: 1%;text-align: right;padding-right: 2%;">
                    <button onclick="summit_data('audit')" style="letter-spacing: 3px;width: 100px;height: 30px;margin-top: 5px;border-radius: 1px;border: #00a0e9 solid 1px;text-align: center;background: #00a0e9;color: white;">同意</button>
                    <button onclick="summit_data('draft')" style="letter-spacing: 3px;width: 100px;height: 30px;margin-top: 5px;border-radius: 1px;border: #00a0e9 solid 1px;text-align: center;background: #00a0e9;color: white;margin-left: 15px;">退回修改</button>
                </div>
            </div>
        </div>
    </div>

    <div id="clsp_detail" style="width: 100%;height: 95.5%;background-color: white;overflow: auto;">
        <div style="width: 100%;height: 99%;display: inline-block;vertical-align: center;">
            <div style="width: 95%;margin-left: 2.5%;">
                <table style="margin-top: 20px;width: 100%;">
                    <tr style="width: 100%;">
                        <td colspan="4" style="width: 100%;text-align: center;border: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;letter-spacing: 2.5px;font-size: 20px;"><strong>公务用车使用审批单</strong></td>
                    </tr>
                    <tr style="width: 100%;">
                        <td colspan="4" style="width: 95%;margin-left: 2.5%;margin-top: 1%;height: 40px;padding-left: 0.5%;line-height: 40px;background: #dfdfdf;border: #cfcfcf solid 0.5px;border-bottom: none;">申请详情</td>
                    </tr>
                </table>
                <table id="car_table" style="width: 100%;">
                    <tr style="margin-left: 1%;">
                        <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;letter-spacing: 1.7px;">
                            申&nbsp;&nbsp;&nbsp;请&nbsp;&nbsp;&nbsp;人
                        </td>
                        <td id="applicat" style="width: 35%;height: 35px;line-height: 35px;padding-left: 1%;border: #cfcfcf solid 0.5px;">{{ v_obj.apply_user.real_name }}</td>

                        <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;">
                            申请部门
                        </td>
                        <td id="department" style="width: 35%;border: #cfcfcf solid 0.5px;padding-left: 1%;line-height: 35px;">{{ v_obj.apply_user.company.name }}</td>
                    </tr>
                    <tr style="margin-left: 1%;">
                        <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;">
                            开&nbsp; 始&nbsp;时&nbsp;间
                        </td>
                        <td id="start_time" style="width: 35%;height: 35px;line-height: 35px;padding-left: 1%;border: #cfcfcf solid 0.5px;">
                            {% if is_edit == 'true' %}
                                <input class="input-style" type="text" name="car_start" id="car_start" autocomplete="off" value="{{ v_obj.start_time|date:'Y-m-d H:i:s' }}" placeholder="{{ v_obj.start_time|date:'Y-m-d H:i' }}">
                            {% else %}
                                {{ v_obj.start_time|date:'Y-m-d H:i' }}
                            {% endif %}
                        </td>

                        <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;">
                            结束时间
                        </td>
                        <td id="end_time" style="width: 35%;border: #cfcfcf solid 0.5px;padding-left: 1%;line-height: 35px;">
                            {% if is_edit == 'true' %}
                                <input class="input-style" type="text" name="car_end" id="car_end" autocomplete="off" value="{{ v_obj.end_time|date:'Y-m-d H:i:s' }}" placeholder="{{ v_obj.end_time|date:'Y-m-d H:i' }}">
                            {% else %}
                                {{ v_obj.end_time|date:'Y-m-d H:i' }}
                            {% endif %}
                        </td>
                    </tr>
                    {% if v_obj.drivers %}
                        <tr style="margin-left: 1%;">
                            <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;border-top: none;">
                                拟&nbsp; 派&nbsp;车&nbsp;辆
                            </td>
                            <td id="vehicle_name" style="width: 35%;height: 35px;line-height: 35px;padding-left: 1%;border: #cfcfcf solid 0.5px;border-top: none;">{{ v_obj.vehicles }}</td>

                            <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;border-top: none;letter-spacing: 1.2px;">
                                司&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;机
                            </td>
                            <td id="driver_name" style="width: 35%;border: #cfcfcf solid 0.5px;padding-left: 1%;line-height: 35px;border-top: none;">{{ v_obj.drivers }}</td>
                        </tr>
                    {% endif %}
                    <tr style="margin-left: 1%;">
                        <td style="width: 15%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;text-align: right;">
                            行&nbsp; 程&nbsp;路&nbsp;线
                        </td>
                        <td id="itinerary" colspan="3" style="width: 85%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;" contenteditable="{{ is_edit }}">{{ v_obj.route }}</td>
                    </tr>
                    <tr style="margin-left: 1%;">
                        <td style="width: 15%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;text-align: right;">
                            用&nbsp; 车&nbsp;人&nbsp;员
                        </td>
                        <td id="field_leader" colspan="3" style="width: 85%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;" {% if is_edit == 'true' %} onclick="model_line()" {% endif %}>{{ v_obj.field_leader }}</td>
                    </tr>

                    <tr style="margin-left: 1%;">
                        <td style="width: 15%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;text-align: right;">
                            用&nbsp; 车&nbsp;事&nbsp;由
                        </td>
                        <td id="car_marks" colspan="3" style="width: 85%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;" contenteditable="{{ is_edit }}">{{ v_obj.subject }}</td>
                    </tr>

                    <tr style="width: 100%;">
                        <td colspan="4" style="width: 95%;margin-left: 2.5%;margin-top: 1%;height: 40px;padding-left: 0.5%;line-height: 40px;background: #dfdfdf;border: #cfcfcf solid 0.5px;border-top: none;">审批详情</td>
                    </tr>

                    {% if 'B' in audit_dic %}
                        <tr style="width: 100%;{% if obj.is_leader == True %} display: none{% endif %}">
                            <td style="width: 15%;height: 150px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;">
                                {% if v_obj.apply_user.company.id == 80 %}
                                    科&nbsp;室&nbsp;负&nbsp;责&nbsp;人
                                {% else %}
                                    分&nbsp;&nbsp;&nbsp;管&nbsp;&nbsp;&nbsp;领&nbsp;&nbsp;&nbsp;导
                                {% endif %}
                            </td>
                            <td colspan="3" style="width: 85%;height: 150px;border: #cccccc solid 1px;border-left: none;border-top: none;">
                                {% for k,v in audit_dic.items %}
                                    {% if k == 'B' %}
                                        {% for item in v %}
                                            {% if item.state != 'unaudit' %}
                                                <div style="width: 100%;line-height: 20px;position: relative;">
                                                    <span>{{ item.state_display }}</span>
                                                    <span style="margin-left: 3%">{{ item.audit_note }}</span>
                                                </div>
                                                <div>
                                                    <img src="{{ item.signature_picture }}" alt="" style="width: 150px; height: 60px;">
                                                </div>
                                                <div style="text-align: right;color: #0b0b0b;">{{ item.audit_time }}</div>
                                            {% endif %}
                                        {% endfor %}
                                    {% endif %}
                                {% endfor %}
                            </td>
                        </tr>
                    {% endif %}

                    {% if 'YB' in audit_dic %}
                        <tr style="width: 100%;{% if obj.is_leader == True %} display: none{% endif %}">
                            <td style="width: 15%;height: 150px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;letter-spacing: 2.2px;">
                                车&nbsp;队&nbsp;负&nbsp;责&nbsp;人
                            </td>
                            <td colspan="3" style="width: 85%;height: 150px;border: #cccccc solid 1px;border-left: none;border-top: none;">
                                {% for k,v in audit_dic.items %}
                                    {% if k == 'YB' %}
                                        {% for item in v %}
                                            {% if item.state != 'unaudit' %}
                                                <div style="width: 100%;line-height: 20px;position: relative;">
                                                    <span>{{ item.state_display }}</span>
                                                    <span style="margin-left: 3%">{{ item.audit_note }}</span>
                                                </div>
                                                <div>
                                                    <img src="{{ item.signature_picture }}" alt="" style="width: 150px; height: 60px;">
                                                </div>
                                                <div style="text-align: right;color: #0b0b0b;">{{ item.audit_time }}</div>
                                            {% endif %}
                                        {% endfor %}
                                    {% endif %}
                                {% endfor %}
                            </td>
                        </tr>
                    {% endif %}

                    {% if 'CGB' in audit_dic %}
                        <tr style="width: 100%;{% if obj.is_leader == True %} display: none{% endif %}">
                            <td style="width: 15%;height: 150px;border: #cccccc solid 1px;text-align: right;padding-right: 1%;border-top: none;">
                                车管办分管领导
                            </td>
                            <td colspan="3" style="width: 85%;height: 150px;border: #cccccc solid 1px;border-left: none;border-top: none;">
                                {% for k,v in audit_dic.items %}
                                    {% if k == 'CGB' %}
                                        {% for item in v %}
                                            {% if item.state != 'unaudit' %}
                                                <div style="width: 100%;line-height: 20px;position: relative;">
                                                    <span>{{ item.state_display }}</span>
                                                    <span style="margin-left: 3%">{{ item.audit_note }}</span>
                                                </div>
                                                <div>
                                                    <img src="{{ item.signature_picture }}" alt="" style="width: 150px; height: 60px;">
                                                </div>
                                                <div style="text-align: right;color: #0b0b0b;">{{ item.audit_time }}</div>
                                            {% endif %}
                                        {% endfor %}
                                    {% endif %}
                                {% endfor %}
                            </td>
                        </tr>
                    {% endif %}
                </table>
            </div>
        </div>
    </div>

    <div id="staff-select" class="shade">
        <div id="staff-model" style="width: 100%;height: 100%;position: absolute;">
            <div style="width: 900px;height: 500px;background: #F5F5F5;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="staff-box" style="width: 100%;height: 40px;background: #f4f7fa;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 20%;margin-left: 1%;display: inline-block;line-height: 40px;font-size: 14px;">
                        选择人员
                    </div>
                    <span onclick="close_model()" style="float: right;padding-right: 2%;cursor: pointer;line-height: 40px;">
                        <i class="iconfont icon-quchu"></i>
                    </span>
                </div>
                <div style="height: 460px;width: 100%;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 70px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div id="dep" class="navigation navigation_color" onclick="change_navigation(this)">部门</div>
                        <div id="limits" class="navigation" onclick="change_navigation(this)">权限</div>
                        <div id="fun" class="navigation" onclick="change_navigation(this)">职能</div>
                    </div>
                    <div style="width: 200px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div style="width: 100%;height: 50px;line-height: 50px;">
                            <input id="SearchDep" onkeydown="SearchDepartment()" class="search_input" type="text" placeholder="搜索" autocomplete="off" style="width: 95%;">
                        </div>
                        <div id="SecondaryNavigation" style="width: 100%;height: 403px;line-height: 50px;overflow: auto;"></div>
                    </div>
                    <div style="width: 200px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div style="width: 100%;height: 50px;line-height: 50px;padding-left: 2%;">
                            <input type="checkbox" id="select-all" onclick="SelectAll(this)">
                            <input id="SearchPeo" onkeydown="SearchProple()" class="search_input" type="text" placeholder="搜索" autocomplete="off" style="width: 87%;">
                        </div>
                        <div id="ThreeNavigation" style="width: 100%;height: 403px;line-height: 50px;overflow: auto;"></div>
                    </div>
                    <div style="width: 370px;height: 100%;display: inline-block;vertical-align: top;overflow: auto">
                        <div style="width: 100%;height: 40px;text-align: left;font-size: 14px;line-height: 40px;">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;已选 <span id="selected-number">0</span> 人
                        </div>
                        <div id="selected-div" style="width: 100%;font-size: 14px;height: 370px;overflow: auto;line-height: 20px;">

                        </div>
                        <div style="width: 100%;font-size: 14px;height: 40px;text-align: center;">
                            <button onclick="IdentifyPersonnel()" style="width: 100px;height: 30px;line-height: 25px;text-align: center;letter-spacing: 5px;border-radius: 3px;border: #cfcfcf solid 1px;font-size: 14px;cursor: pointer;margin-top: 10px;">完成</button>
                            <button onclick="close_model()" style="margin-left: 15px;width: 100px;height: 30px;line-height: 25px;text-align: center;color: #0abb78;letter-spacing: 5px;border-radius: 3px;font-size: 14px;border: #cfcfcf solid 1px;cursor: pointer;margin-top: 10px;">取消</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}


{% block script %}
    <script language="javascript" src="../../static/personal_center/js/jquery-1.4.4.min.js"></script>
    <script language="javascript" src="../../static/personal_center/js/jquery.jqprint-0.3.js"></script>
    <script src="../../static/administrative/layDate-v5.0.9/laydate/laydate.js"></script> <!-- 改成你的路径 -->
    <script src="../../static/public_file/js/PersonnelChoosersNew.js" type="text/javascript" charset="gb2312"></script>
    <script>
        window.onload = function () {
            document.getElementById("sponsor").className = "add_class";
            document.getElementById("personage").className = "add-nav-active";
        };

        lay('#version').html('-v' + laydate.v);

        //执行一个laydate实例
        laydate.render({
            elem: '#car_start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#car_end' //指定元素
        });

        let appave_title = document.querySelector("#appave-title");
        let examine_model = document.querySelector("#examine-model");

        appave_title.addEventListener("mousedown", function (e) {
            let x = e.pageX - examine_model.offsetLeft;
            let y = e.pageY - examine_model.offsetTop;
            document.addEventListener("mousemove", move);

            function move(e) {
                examine_model.style.left = e.pageX - x + 'px';
                examine_model.style.top = e.pageY - y + 'px';
            }

            document.addEventListener("mouseup", function (e) {
                document.removeEventListener("mousemove", move);
            })
        });

        function summit_data(approve) {
            var present_id = window.location.href.split("id=")[1].replace("#", '');
            var audit_note = document.getElementById("opinion_detail").value;

            if (document.getElementById("select_tag")) {
                var vehicles = $("#select_tag").find("option:selected").text();
                var drivers = $("#select_drive").find("option:selected").text();
            }else {
                vehicles = '';drivers = '';
            }

            if (approve === "draft") {
                if (!audit_note) {
                    alert("不同意请填写理由！");
                    return false
                }
            }
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/personal-center/VehicleApplyDetail");
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
            xhr.send("id=" + present_id + "&state=" + String(approve) + "&audit_note=" + String(audit_note) + "&vehicles=" + String(vehicles) + "&drivers=" + String(drivers));
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate["code"] === 200) {
                            alert("审批成功");
                            window.location.href = "/personal-center/process_management.html?type=我的待办&folw_type=&folw=&page=1&page_size=20&wd=";
                        } else {
                            alert(JsonDate["message"]);
                        }
                    }
                }
            };
        }

        function online_tag() {
            document.getElementById("appave-model").style.display = "table-cell";
        }

        function close_models() {
            document.getElementById("appave-model").style.display = "none";
        }

        function page_zhanshi() {
            document.getElementById('page_one').style.display = 'inline-block';
        }

        function page_yincang() {
            document.getElementById('page_one').style.display = 'none';
        }

        function but_click() {
            $('#clsp_detail').jqprint({
                debug: false,
                importCSS: true,
                printContainer: true,
                operaSupport: false
            });
        }

        function operate_button(ele_id) {
            var url = window.location.href;
            var id = url.split("id=")[1];
            console.log(ele_id)
            if (ele_id === 'is_stop') {
                var state = 'stop';     // 终止
                var word = '终止'
            } else if (ele_id === 'is_cancel') {
                state = 'cancel';       // 作废
                word = '作废'
            } else{
                state = 'recall'
                word = '撤回'
            }
            var r = confirm('是否'+word+'流程？')
            if (r == true) {
                var xhr = new XMLHttpRequest();
                var local_host = window.location.host;          // 获取当前IP
                xhr.open('post', "/personal-center/vehicle_apply_cancel_view", true);
                xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
                xhr.send("state=" + state + "&id=" + id)
                xhr.onreadystatechange = function () {
                    if (xhr.readyState === 4) {
                        if (xhr.status === 200) {
                            document.getElementById("loading").style.display = "none";
                            var JsonDate = JSON.parse(xhr.responseText);
                            alert(JsonDate['message'])
                            window.location.href = '/personal-center/vehicle_person_apply'
                        }
                    }
                };
            }
        }

        function scrollConversationScreen() {
            $('#selected-div').scrollTop($('#selected-div')[0].scrollHeight);
        }

        function IdentifyPersonnel() {
            var prople_list = [];
            var selected_personnel_list = document.getElementsByClassName('selected-personnel');
            for (var i=0; i<selected_personnel_list.length; i++) {
                prople_list.push(selected_personnel_list[i].innerText)
            }
            document.getElementById("field_leader").innerText = prople_list.join();
            close_model()
        }

        function ExportCar() {
            var car_start = document.getElementById('car_start').value;             // 开始时间
            var car_end = document.getElementById('car_end').value;         // 结束时间
            var itinerary = document.getElementById("itinerary").innerText;         // 行程路线
            var field_leader = document.getElementById("field_leader").innerText;
            var car_marks = document.getElementById('car_marks').innerText;             // 用车是由

            if (!field_leader) {
                alert("请选择同行领导！");
                return false
            }

            document.getElementById("loading").style.display = "inline-block";
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/personal-center/vehicle_apply_index", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("id={{ v_obj.id }}&subject=" + String(car_marks) + "&start_time=" + String(car_start) + "&end_time=" + String(car_end) + "&route=" + String(itinerary) + "&field_leader=" + String(field_leader));
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate["code"] === 200) {
                            alert("修改成功！");
                            window.location = "/personal-center/vehicle_use_info_view";
                            document.getElementById("loading").style.display = "none";
                        } else {
                            alert(JsonDate['message']);
                            document.getElementById("loading").style.display = "none";
                        }
                    }
                }
            };

        }
    </script>
{% endblock %}
